import React, {Component} from 'react';

export default class Control extends Component{
    state = {val:''}  //声明一个状态

    get = ()=>{
        // let val = document.querySelector('input').value;
        // console.log(val);
        console.log(this.state.val)   //绑定了一个事件，受状态控制
    }
    
    changeVal = (e)=>{    //事件处理函数 事件绑定
        
        this.setState({val:e.target.value})
        console.log(888);   
    }
    render() {
        const {val} =this.state;
        return (
            <div>
                <input 
                    onChange={this.changeVal} 
                    value={val}
                    placeholder = "请输入内容"
                /> 
                <input ref='inp'/>
                <input />
                <button onClick={this.get}>打印输入内容</button>
            </div>
        )
    }
}